//
//  GJWBaseRequest.m
//  GuiJuWo
//
//  Created by chenguibang on 16/3/25.
//  Copyright © 2016年 chenguibang. All rights reserved.
//

#import "GJWBaseRequest.h"
#define JSON_BODY_REUEST   @"com.ailk.app.mapp.model.req.%@Request" //接口号类
#define JSON_HEADER @"\"@class\":\"com.ailk.app.mapp.model.GXCHeader\",\"bizCode\":\"%@\",\"identityId\":null,\"respCode\":null,\"respMsg\":null,\"mode\":\"1\",\"sign\":null"
@implementation GJWBaseRequest


-(NSDictionary *)dicttionaryOfparmaters{
    
    NSString *headJson = [[NSString alloc] initWithFormat:JSON_HEADER,[self.head.bizCode  uppercaseString]];
    NSDictionary *headDict = [NSDictionary dictionaryWithObjectsAndKeys:
                              @"com.ailk.app.mapp.model.GXCHeader",@"@class",
                              self.head.bizCode,@"bizCode",
                              self.head.sessionId == nil? [NSNull null]:self.head.sessionId,@"identityId",
                              [NSNull null],@"respCode",
                              [NSNull null],@"respMsg",
                              @"1",@"mode",
                              [NSNull null],@"sign",
                               nil];
    NSString *requestClass = [[NSString alloc] initWithFormat:JSON_BODY_REUEST,[self.head.bizCode  uppercaseString]];
    NSMutableDictionary *bodyData = [self.body mj_keyValues];
    [bodyData setValue:requestClass forKey:@"@class"];
    
    NSDictionary *paramters = [NSDictionary dictionaryWithObjectsAndKeys:
                               @"com.ailk.app.mapp.model.GXCDatapackage",@"@class",
                               headDict,@"header",
                               bodyData,@"body",
                               nil];
    return paramters;
    
}

-(GJWRequestHead *)head{
    if (!_head) {
        _head = [[GJWRequestHead alloc]init];
    }
    return _head;
}

-(GJWRequestBody *)body{
    if (!_body) {
        _body = [[GJWRequestBody alloc]init];
    }
    return _body;
}


/**
 *  更改服务器地址 在pch 里改变一面
 *
 *  @return
 */
-(NSString *)baseUrl{
    NSString *serverIp = nil;
#ifdef DEBUG
    serverIp = @"http://10.37.238.51:8888/wgj-base-web/";
#else
    serverIp = @"http://10.37.238.51:8888/wgj-base-web/";
#endif
    return [NSString stringWithFormat:@"%@/mapp/json.do",serverIp];
}
@end
